Skip to content

fix(MainNavigationBar): allow right slot to expand#1546

Open
AlexandraGallipoliRodrigues wants to merge 22 commits into
masterfrom
alex/OBVIVO-3456-fix-MainNavigationBar-allow-right-slot-to-expand
Open

fix(MainNavigationBar): allow right slot to expand#1546
AlexandraGallipoliRodrigues wants to merge 22 commits into
masterfrom
alex/OBVIVO-3456-fix-MainNavigationBar-allow-right-slot-to-expand

Conversation

@AlexandraGallipoliRodrigues
Copy link
Copy Markdown
Contributor

@AlexandraGallipoliRodrigues AlexandraGallipoliRodrigues commented May 6, 2026

ticket: https://jira.tid.es/browse/WEB-2439
figma: https://www.figma.com/design/HA6UnnWC187IL1YujMYlYZ/Main-Navigation-Bar?node-id=2412-5583

  • Inline expand prop: allows you to specify which Inline child should occupy the remaining space.

bug:
image

fix, local playroom:
image

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Size stats

master this branch diff
Total JS 16.1 MB 16.1 MB +1.28 kB
JS without icons 2.01 MB 2.01 MB +1.24 kB
Lib overhead 92.5 kB 92.5 kB 0 B
Lib overhead (gzip) 19.9 kB 19.9 kB 0 B

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Deploy preview for mistica-web ready!

Project:mistica-web
Status: ✅  Deploy successful!
Preview URL:https://mistica-iqcr846ee-flows-projects-65bb050e.vercel.app
Latest Commit:9656fd7

Deployed with vercel-action

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Accessibility report
✔️ No issues found

ℹ️ You can run this locally by executing yarn audit-accessibility.

@AlexandraGallipoliRodrigues AlexandraGallipoliRodrigues marked this pull request as ready for review May 6, 2026 10:10
Copilot AI review requested due to automatic review settings May 6, 2026 10:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes layout limitations in MainNavigationBar/NavigationBar right content so the right slot can properly expand when the provided right element is intended to be full-width, and introduces a new InlineItem API to allow individual inline children to opt into flex-grow behavior.

Changes:

  • Wrap right content in NavigationBarContentContainer when expandRightContent is enabled and the right element has fullWidth, plus add supporting CSS to allow correct shrinking/expansion.
  • Add InlineItem with grow support so specific Inline children can expand, and switch Inline rendering to inspect children for grow items.
  • Re-export InlineItem from the library entrypoint.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/navigation-bar.tsx Conditionally wraps right slot content to allow full-width expansion when requested.
src/navigation-bar.css.ts Tweaks expanded right-slot sizing and adds a wrapper style for full-width content.
src/inline.tsx Adds InlineItem API and updates child rendering to support grow items.
src/inline.css.ts Adds flex container and grow-item styles needed for the new InlineItem behavior.
src/index.tsx Exposes InlineItem from the public package API.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/inline.tsx Outdated
Comment on lines +133 to +136

return (
<div
key={index}
Copilot AI review requested due to automatic review settings May 6, 2026 11:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated no new comments.

Comment thread src/inline.tsx
Copy link
Copy Markdown
Contributor

@yceballost yceballost May 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont feel really easy in terms of devExp to have another component called InlineItem to manage this kind of things

Is not there any other solution? maybe manage this property in the <Inline> component?

wdyt @atabel ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, thanks! I’ve removed the public InlineItem component and moved the behavior into Inline via a growItems prop

Copilot AI review requested due to automatic review settings May 7, 2026 14:06
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Size stats

master this branch diff
Total JS 16.1 MB 16.1 MB +325 B
JS without icons 2.02 MB 2.02 MB +325 B
Lib overhead 92.5 kB 92.5 kB 0 B
Lib overhead (gzip) 19.9 kB 19.9 kB 0 B

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Comment thread src/inline.tsx Outdated
Comment on lines 127 to 128
hasGrowItem && styles.flexLayout,
isStringSpace ? (wrap ? styles.stringSpaceWithWrap : styles.stringSpace) : styles.marginInline
Copilot AI review requested due to automatic review settings May 8, 2026 07:49
Copilot AI review requested due to automatic review settings May 11, 2026 10:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 10 changed files in this pull request and generated no new comments.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 11, 2026

Screenshot tests report

✔️ All passing

Comment thread src/navigation-bar.css.ts Outdated
]);

export const navigationBarContentRightExpandedContent = style({
width: '100%',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about an expand prop on the Inline element? It would set its width to 100% whenever it is set. This way we wouldn't have to modify navigation bar I think. This prop could accept what you currently have in flexGrow prop and wouldn't need fullWidth to be set.

Copy link
Copy Markdown
Contributor Author

@AlexandraGallipoliRodrigues AlexandraGallipoliRodrigues May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like this?

Copilot AI review requested due to automatic review settings May 12, 2026 10:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.

Comment thread src/inline.tsx Outdated
Comment on lines 121 to 138
const childrenArray = React.Children.toArray(children).filter((child) => !!child || child === 0);

const hasExpandItem = childrenArray.some((_, index) => shouldExpandItem(expand, index));
const shouldExpand = expand !== undefined;

return (
<div
className={classnames(
className,
styles.inline,
wrap ? styles.wrap : fullWidth ? styles.fullWidth : styles.noFullWidth,
isStringSpace ? (wrap ? styles.stringSpaceWithWrap : styles.stringSpace) : styles.marginInline
wrap ? styles.wrap : fullWidth || shouldExpand ? styles.fullWidth : styles.noFullWidth,
isStringSpace
? wrap
? styles.stringSpaceWithWrap
: styles.stringSpace
: styles.marginInline,
shouldExpand && styles.expand
)}
Comment thread src/inline.tsx
dataAttributes?: DataAttributes;
wrap?: boolean;
/**
* Index or indexes of the children that should grow to fill the available space.
const {isDesktopOrBigger} = useScreenSize();

const right = expandedRightSlot ? (
<Inline fullWidth space={16} alignItems="center" expand={0}>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can skip fullWidth prop here, right?

Comment thread src/inline.css.ts Outdated

export const expandItem = style({
flex: 1,
minWidth: 0,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the minWidth?

Copy link
Copy Markdown
Contributor Author

@AlexandraGallipoliRodrigues AlexandraGallipoliRodrigues May 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minWidth: 0 was intentional here. In a flex layout, flex items have min-width: auto by default, so an expanded item can refuse to shrink below its content size and push adjacent items out of the available space. Setting minWidth: 0 allows the expanded item to shrink properly and lets inner components handle truncation/overflow... But i haven't been able to prove this case in a playroom, should I delete the minWidth then?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I don't know if that behaviour is desirable, perhaps we could live without it for the moment...
https://developer.mozilla.org/en-US/play?id=pEK8gpiRaKCWYKNxPpXPkgOoAEQy8NkIAdjrAPjKL0gP%2BAzWTL%2FLoG9rA2WXLAksvUN8leTXOzoc46Dg

Comment thread src/inline.tsx Outdated
{childrenArray.map((child, index) => {
return (
<div
key={getChildKey(child, index)}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use React.Children.map because key logic is handled automatically:

Image

Comment thread src/inline.tsx Outdated
}: Props): JSX.Element => {
const {platformOverrides} = useTheme();
const isStringSpace = typeof space === 'string';
const childrenArray = React.Children.toArray(children).filter((child) => !!child || child === 0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the doc react filters empty elements:

Image

Copilot AI review requested due to automatic review settings May 13, 2026 09:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.

Comment thread src/inline.tsx Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 13, 2026 10:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.

Comment thread src/inline.tsx Outdated
Comment thread src/inline.tsx Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 13, 2026 10:34
added !wrap

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.

Comment thread src/inline.tsx Outdated
Comment on lines +84 to +87
* Indexes refer to entries in `React.Children.toArray(children)`, so empty nodes
* (`null`, `undefined` and booleans) are ignored, but React elements still count
* even if they ultimately render no content. Expanded children must render content
* to produce a visible expanded item.
Comment thread src/inline.tsx
Comment on lines 123 to 132
className,
styles.inline,
wrap ? styles.wrap : fullWidth ? styles.fullWidth : styles.noFullWidth,
isStringSpace ? (wrap ? styles.stringSpaceWithWrap : styles.stringSpace) : styles.marginInline
wrap ? styles.wrap : fullWidth || hasExpandItem ? styles.fullWidth : styles.noFullWidth,
isStringSpace
? wrap
? styles.stringSpaceWithWrap
: styles.stringSpace
: styles.marginInline,
hasExpandItem && !wrap && styles.expand
)}
Copilot AI review requested due to automatic review settings May 14, 2026 07:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated 3 comments.

Comment thread src/inline.tsx
Comment on lines +117 to +120
const childrenArray = React.Children.toArray(children).filter((child) => child !== '');

const hasExpandItem = childrenArray.some((_, index) => shouldExpandItem(expand, index));
const shouldExpand = hasExpandItem && !wrap;
Comment thread src/inline.tsx
Comment on lines +82 to +90
/**
* Index or indexes of the children that should grow to fill the available space.
* Indexes refer to entries in `React.Children.toArray(children)`, so empty nodes
* (`null`, `undefined` and booleans) are ignored, but React elements still count
* even if they ultimately render no content.
*
* This prop has no effect when `wrap` is enabled.
*/
expand?: number | ReadonlyArray<number>;
Comment thread src/inline.css.ts
});

export const expandItem = style({
flex: 1,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants